<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of listing_model
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Listing_model extends CI_Model {

    function add($post) {
        if ($post) {
            $this->db->insert('listing_master', $post);
            return "<strong>Thank you!</strong> &nbsp; 
                you have successfully entered your car Information. Please goto  
                <strong>Member Area</strong> for PHOTOS AND OTHER DETAIL.";
        } else {
            return "<strong>Sorry !</strong> &nbsp; Invalid Operation.";
        }
    }

    function search($query=NULL, $type=NULL) {
        if ($type == 'car') {
            $sql = "Select * from listing_master where status = 51";
            if ($query['car_make']) {
                $sql.= " and make = " . $query['car_make'];
            }
            if ($query['car_model']) {
                $sql.= " and model = " . $query['car_model'];
            }
            if ($query['car_country']) {
                $sql.= " and country = " . $query['car_country'];
            }
            if ($query['car_state']) {
                $sql.= " and state = " . $query['car_state'];
            }
            if ($query['car_city']) {
                $sql.= " and city = " . $query['car_city'];
            }
            if ($query['car_min_year']) {
                $sql.= " and make_year >= " . $query['car_min_year'];
            }
            if ($query['car_max_year']) {
                $sql.= " and make_year <= " . $query['car_max_year'];
            }
            if ($query['car_budget']) {
                $sql.= " and price <= " . $query['car_budget'];
            }
            //print $sql;
            $query = $this->db->query($sql);
            $result = $query->result();
            return $result;
            
           
             
        }
    }

}

?>
